# def get_max1(num1,num2):
#     max = num1
#     if num2 > max:
#         max = num2
#     return max
# print(get_max1(7,3))
#
# def get_max2(num1,num2,num3):
#     max = num1
#     if num2 > max:
#         max=num2
#     if num3 > max:
#         max=num3
#     return max
# print(get_max2(3,6,7))
#
# def panduan(num1,num2,num3):
#     max=num1
#     if num2 > max:
#         max = num2
#     if num3 > max:
#         max = num3
#     return max
# print(panduan(8,5,4))
#
# def panduan2(student_list):
#     max = student_list[0]
#     for index,num in enumerate(student_list):
#         if num > max:
#             max = num
#     return max
# student_list=[1,2,3,8]
# print(panduan2(student_list))
#
# def panduan2(student_list):
#     max = student_list[0]
#     for index,num in enumerate(student_list):
#         if num > max:
#             max = num
#     return max
# student_list=[1,2,3,5]
# print(panduan2(student_list))





# def panduan(num1,num2):
#     max=num1
#     if num2 > max:
#         max = num2
#     return max
# print(panduan(5,3))
#
# def panduan2(num1,num2,num3):
#     max = num1
#     if num2 > max:
#         max = num2
#     if num3 > max:
#         max = num3
#     return max
# print(panduan2(9,8,7))
#
#
# def panduan3(student_list):
#     max = student_list[0]
#     for index,num in enumerate(student_list):
#         if num > max:
#             max = num
#     return max
# student_list=[10,9,3,8]
# print(panduan3(student_list))
#
#
#
#
# def panduan4(student_list):
#     max = student_list[0]
#     for index,num in enumerate(student_list):
#         if num > max:
#             max = num
#     return max
# print(panduan4(student_list=[10,11,9,7,8,12]))














students = [
    {'name': '小明', 'age': 10, 'sex': 'male'},
    {'name': '小红', 'age': 12, 'sex': 'female'},
    {'name': '小李', 'age': 12, 'sex': 'male'}
]

def panduan1():
    print('{:<10}{:<10}{:<10}{:<10}'.format('编号','姓名','年龄','性别'))
    print('~'*50)
    for i in range(0,len(students)):
        num=students[i]
        name=num['name']
        age=num['age']
        sex=num['sex']
        print('{:<10}{:<10}{:<10}{:<10}'.format(i+1,name,age,sex))
        print('-'*50)
def panduan2():
    name=input('请输入你要添加的学生姓名:')
    age=int(input('请输入你要添加的年龄:'))
    sex=input('请输入你要添加的性别:')
    if sex!= '男' and sex!='女' and sex!='male' and sex!='female':
        print('输入错误，你输入的不是性别 "{}"'.format(sex))
        panduan2()
    student_list={
        'name':name,
        'age':age,
        'sex':sex
    }
    students.append(student_list)
def panduan3():
    panduan1()
    num=int(input('请根据编号进行修改:'))
    while num<1 or num>len(students):
        num=int(input('输入错误,超出范围,请重新输入:'))
    name=input('请输入你要修改的名字:')
    age=int(input('请输入你要修改的年龄:'))
    sex=input('请输入你要修改的年龄:')
    students[num-1]['name']=name
    students[num-1]['age']=age
    students[num-1]['sex']=sex

    # panduan1()
    # num = int(input('请根据编号修改信息:'))
    # while num < 1 or num > len(students):
    #     num = int(input('输入错误,请重新输入:'))
    # name = input('请输入你要修改的名字:')
    # age = int(input('请输入要修改的年龄:'))
    # sex = input('请输入你要修改的性别:')
    # students[num - 1]['name'] = name
    # students[num - 1]['age'] = age
    # students[num - 1]['sex'] = sex
    # print("""
    #         ————
    #         修改成功
    #         ————
    #     """)




def zong():
    while True:
        print("""小金>欢迎使用小金系统
            1-查询所有信息
            2-添加学生姓名
            3-修改学生姓名
            4-删除学生姓名
            0-退出程序
        """)
        num = int(input('请输入你要操作的序号:'))
        while num < 0 or num>4:
            num = int(input('输入错误,请重新输入:'))
        if num==1:
            panduan1()
        elif num==2:
            panduan2()
        elif num==3:
            panduan3()
        elif num==4:
            panduan4()
        elif num==0:
            print("""
            ------
            小金系统
                使用结束
            """)
            break
if __name__=='__main__':
    zong()














